{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "63ab391a",
   "metadata": {},
   "source": [
    "# Stress Test Results\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "53e60d14",
   "metadata": {},
   "outputs": [],
   "source": [
    "from utils import LogFile"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ee4c7fb0",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true,
     "source_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-040-40th-1000-steps-30s-50-batch-no-rbac-endpoint-metrics.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-041-40th-1000-steps-30s-50-batch-no-rbac-no-service-connector.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-042-20th-1000-steps-30s-50-batch-no-rbac-no-service-connector.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-043-2th-1000-steps-30s-50-batch-no-rbac-no-service-connector.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-044-4th-1000-steps-30s-50-batch-no-rbac-no-service-connector.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-044-4th-1000-steps-30s-50-batch-no-rbac-no-service-connector-take-2.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-045-8th-1000-steps-30s-50-batch-no-rbac-no-service-connector.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-046-8th-1000-steps-30s-50-batch-no-rbac.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-047-2th-1000-steps-30s-50-batch-no-rbac.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-048-2th-1000-steps-30s-50-batch.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-049-4th-1000-steps-30s-50-batch.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-050-8th-1000-steps-30s-50-batch.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-050-8th-1000-steps-30s-50-batch-take-2.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-050-8th-1000-steps-30s-50-batch-take-3.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-051-8th-1000-steps-30s-50-batch-deduplication.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-052-8th-1000-steps-30s-50-batch-deduplication-take-2.txt\")\n",
    "# log_file = LogFile.parse_logs(\"../../../../docs/aiml/zenml/stress-tests/server-logs-053-2th-1000-steps-30s-50-batch-deduplication.txt\")\n",
    "log_file = LogFile.parse_logs(\n",
    "    \"../../../../docs/aiml/zenml/stress-tests/server-logs-054-2th-1000-steps-30s-50-batch-deduplication-async-auth.txt\"\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "425c47c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# log_file.request_flows[\"b170dbe2\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4b7dab39",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true,
     "source_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "log_file.plot_request_flows(\n",
    "    start_time=200,\n",
    "    end_time=500,\n",
    "    max_requests=5000,\n",
    "    # pps=10,\n",
    "    # width=2000,\n",
    "    height=1000,\n",
    "    width=1900,\n",
    "    # pod=1,\n",
    "    hide_legend=True,\n",
    "    hide_y_axis=True,\n",
    "    # api_call_filter=[\n",
    "    #     \".*/api/v1/service_connectors/<uuid>/client\",\n",
    "    #     \".*/api/v1/runs$\",\n",
    "    #     \".*/api/v1/pipeline_deployments\",\n",
    "    # ],\n",
    "    # min_duration=1,\n",
    "    # group_retry_requests=False,\n",
    "    # filter_states=[LogType.SQL_STARTED, LogType.SQL_COMPLETED],\n",
    "    request_id=\"88ddf46e\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b84ef271",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true,
     "source_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "log_file.plot(\n",
    "    log_file.get_plot_fn(\n",
    "        y_metric=\"threads\",\n",
    "        # y_metric=\"memory_usage\",\n",
    "        # y_metric=\"active_requests\",\n",
    "        label_attribute=\"pod\",\n",
    "    ),\n",
    ")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
